;$(function() {
	var serverIdArr='';
	var id = $("#id").val();
	if(id==null||id==''){
		upload(serverIdArr)
		getProvinceList(null,null,null,null);
    }else{
    	getInfo(id);	
    }
 })
 
 
 
 function getInfo(id){
	   $.ajax({
        url: ctxPath+"/visit/letter/findById/"+id,
        type: 'GET',
        success: function(d){
        	var success = d.success;
        	 if(success==true){
        	 var data=  d.data;
        	 if(data!=null){
        		 $("#title").html(data.title);
        		 $("#content").html(data.content);
        		 var html="";
        		 if(data.files!=null){
        			 $.each(data.files,function(i,item){
        				 html+='<a>'+item.srcname+'</a><br>'; 
        			 })
        		 }
        		 getUser(data.userId);
        		 $("#files").html(html);
        	 }
        	}
        } 
    });
}

function getUser(userId){
	$.ajax({
		url: ctxPath+"/visit/user/findById/"+userId,
		type: 'GET',
		success: function(d){
			var success = d.success;
			if(success==true){
				var data=  d.data;
				if(data!=null){
					$("#phone").html(data.phone);
					$("#idCard").html(data.idCard);
					$("#name").html(data.name);
					$("#sexName").html(data.sexName);
					$("#address").html(data.provinceName+data.cityName+data.countyName+data.detailAddress);
				}
			}
		} 
	});
}

